<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  
</body>
<script>
  // const imgAddr = "https://img2.baidu.com/it/u=702020965,1775807213&fm=26&fmt=auto"
  const imgAddr = "https://img2.baidu.com/it/u=702020965,1775807213&fm=26&fmt=auto123123"
  
  const imgPromise = (url) =>{
    return new Promise ((resolve,reject)=>{
      const img = new Image()
      img.src = url;
      img.onload = () =>{
        resolve(img)
      }
      img.onerror = () =>{
        reject(new Error('图片有误'))
      }
    })
  }

  imgPromise(imgAddr)
    .then(img => {
      document.body.appendChild(img)
    })
    .catch(err =>{
      document.body.innerHTML = err
    })
</script>
</html>